import React from 'react'

import {WeaLocaleProvider} from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;

import './style'
import ContainerModle from '../../common/containerModle'
import AddExtend from './addExtend'
import AddExtendGroup from './addExtendGroup'
import SettingExtend from './settingExtend'
import SettingProxy from './settingProxy'
import ContainerViewExtend from './containerViewExtend'
import ContainerViewProxy from './containerViewProxy'


export default class News extends React.Component{

    static defaultProps = {
        javaInterface:{
            find: '/api/portalTsLogin/element/getNewsData',
            save: '/api/portalTs/customNews/save',
            update: '/api/portalTs/customNews/update',
            saveOrUpdateItem: '/api/portalTs/customNews/saveOrUpdateItem',
            deleteItem: '/api/portalTs/customNews/deleteItem',
            orderItem: '/api/portalTs/customNews/orderItem',
        }
    }

    onSaveBeforeHandler = (setting={})=>{
        setting.title = getLabel(19874, '文档中心')

    }

    onLoadAfterHandler = (data)=>{
        // for(let i in data.eFieldNewDataSource){
        //     if(data.eFieldNewDataSource.hasOwnProperty(i)){
        //         data.eFieldNewDataSource[i].name = getLabel(data.eFieldNewDataSource[i].name, data.eFieldNewDataSource[i].name)
        //     }
        // }
        for(let i in data.orderFields){
            if(data.orderFields.hasOwnProperty(i)){
                data.orderFields[i].fieldNameLabelId = data.orderFields[i].fieldName
                // data.orderFields[i].fieldName = getLabel(data.orderFields[i].fieldName, data.orderFields[i].fieldName)
            }
        }
        for(let i in data.items){
            if(data.items.hasOwnProperty(i)){
                if(data.items[i].unreadData.isHaveNoRead == '1'){
                    data.items[i].countIcon = '/images/ecology8/statusicon/BDNew_wev8.png'
                }else if(data.items[i].unreadData.noReadNum !='' && data.items[i].unreadData.noReadNum != '0'){
                    data.items[i].count = data.items[i].unreadData.noReadNum
                }
            }
        }
    }

    render(){

        return (
            <ContainerModle ecId={`${this && this.props && this.props.ecId || ''}_ContainerModle@vq5heb`} {...this.props} {...(this.props.location ? this.props.location.query :{})} ContainerViewProxy={ContainerViewProxy} SettingProxy={SettingProxy} onSaveBeforeHandler={this.onSaveBeforeHandler} onLoadAfterHandler={this.onLoadAfterHandler} AddExtend={AddExtend} AddExtendGroup={AddExtendGroup} SettingExtend={SettingExtend} ContainerViewExtend={ContainerViewExtend} >
            </ContainerModle>
        )
    }
}